<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- <link rel="shortcut icon" href="./img/favicon.ico"> -->
  <title>Document</title>

</head>

<body>
  <h1>登陆页面</h1>

  <input type="text" class="username" name="username"> <br>
  <input type="text" class="pwd" name="pwd"> <br>
  <input type="button" class="btn" value="提交">

  <script src="./js/axios.js"></script>
  <script>
    const username = document.querySelector('.username');
    const pwd = document.querySelector('.pwd');
    const btn = document.querySelector('.btn');
    btn.onclick = function () {
      axios.get('/api/login', {
        params: {
          username: username.value.trim(),
          password: pwd.value.trim()
        }
      })
        .then(res => {
          console.log(res.data)
          if (res.data.errno === 0) {
            window.location.href = './prodect.html'
          } else {
            alert('登陆失败，请重新登陆')
          }
        })
    }
  </script>
</body>
</h1>